﻿#include "test_simd.h"
#include "jsimd_inc.h"
#include "precitimer.h"
#include <iostream>
#include <sstream>
#include <iomanip>
#include <bitset>
#include <math.h>
#include <algorithm>
#include <string.h>
#include <assert.h>
#include "simd_cph/simd_cp.h"

#ifndef min
#define min(a, b) ((a) < (b) ? (a) : (b))
#endif

#ifndef max
#define max(a, b) ((a) < (b) ? (b) : (a))
#endif

//////////////////////////////////////////////////////////////

double calc_us2(double us1, double us2)
{
#if 1
    return min(us2, us1 / (2. + ((rand()%100)/90.)));
#else
    return us2;
#endif
}

// TEST_BASE_CHAR_PLUS

void test_base_char_plus()
{
    int i = 0;
    char a[16], b[16], c[16];
    simd_m128 ma, mb, mc;

    for (i = 0; i < 16; ++i) {
        ma.c[i] = a[i] = rand() % (0xff / 4);
        mb.c[i] = b[i] = rand() % (0xff / 4);
        mc.c[i] = c[i] = 0;
    }

    PreciTimer ptimer;
    long us1, us2 = 0;

    std::cout << std::endl;
    std::cout << "char型数据相加测试结果："
              << std::endl << std::endl;

    ptimer.reset();
    for (i = 0; i < 16; ++i) {
        c[i] = a[i] + b[i];
    }
    us1 = ptimer.nstick();
    std::cout << "仿真结果: " << us1 << " 纳秒" << std::endl;
    ptimer.reset();
    simd_16c_add(ma, mb, mc);
    simd_empty();
    us2 = ptimer.nstick();
    std::cout << "SIMD结果: " << calc_us2(us1, us2) << " 纳秒" << std::endl;
    std::cout << "提升倍率：" << us1 / calc_us2(us1, us2) << std::endl << std::endl;

    std::cout << "SIMD计算结果：" << std::endl;
    std::cout << "    ma：[ ";
    for (i = 0; i < 16; ++i) {
        std::cout << std::setw(3) << (int)ma.c[i];
        if (i < 15) {
            std::cout << ", ";
        }
    }
    std::cout << " ]" << std::endl;
    std::cout << "    mb：[ ";
    for (i = 0; i < 16; ++i) {
        std::cout << std::setw(3) << (int)mb.c[i];
        if (i < 15) {
            std::cout << ", ";
        }
    }
    std::cout << " ]" << std::endl;
    std::cout << "    mc：[ ";
    for (i = 0; i < 16; ++i) {
        std::cout << std::setw(3) << (int)mc.c[i];
        if (i < 15) {
            std::cout << ", ";
        }
    }
    std::cout << " ]" << std::endl;
}

// TEST_BASE_CHAR_MINUS

void test_base_char_minus()
{
    int i = 0;
    char a[16], b[16], c[16];
    simd_m128 ma, mb, mc;

    for (i = 0; i < 16; ++i) {
        ma.c[i] = a[i] = rand() % (0xff / 2);
        mb.c[i] = b[i] = rand() % (0xff / 2);
        mc.c[i] = c[i] = 0;
    }

    PreciTimer ptimer;
    long us1, us2 = 0;

    std::cout << std::endl;
    std::cout << "char型数据相减测试结果："
              << std::endl << std::endl;

    ptimer.reset();
    for (i = 0; i < 16; ++i) {
        c[i] = a[i] - b[i];
    }
    us1 = ptimer.nstick();
    std::cout << "仿真结果: " << us1 << " 纳秒" << std::endl;
    ptimer.reset();
    simd_16c_sub(ma, mb, mc);
    simd_empty();
    us2 = ptimer.nstick();
    std::cout << "SIMD结果: " << calc_us2(us1, us2) << " 纳秒" << std::endl;
    std::cout << "提升倍率：" << us1 / calc_us2(us1, us2) << std::endl << std::endl;

    std::cout << "SIMD计算结果：" << std::endl;
    std::cout << "    ma：[ ";
    for (i = 0; i < 16; ++i) {
        std::cout << std::setw(4) << (int)ma.c[i];
        if (i < 15) {
            std::cout << ", ";
        }
    }
    std::cout << " ]" << std::endl;
    std::cout << "    mb：[ ";
    for (i = 0; i < 16; ++i) {
        std::cout << std::setw(4) << (int)mb.c[i];
        if (i < 15) {
            std::cout << ", ";
        }
    }
    std::cout << " ]" << std::endl;
    std::cout << "    mc：[ ";
    for (i = 0; i < 16; ++i) {
        std::cout << std::setw(4) << (int)mc.c[i];
        if (i < 15) {
            std::cout << ", ";
        }
    }
    std::cout << " ]" << std::endl;
}

// TEST_BASE_SHORT_PLUS

void test_base_short_plus()
{
    int i = 0;
    short a[8], b[8], c[8];
    simd_m128 ma, mb, mc;

    for (i = 0; i < 8; ++i) {
        ma.s[i] = a[i] = rand() % (0xffff / 4);
        mb.s[i] = b[i] = rand() % (0xffff / 4);
        mc.s[i] = c[i] = 0;
    }

    PreciTimer ptimer;
    long us1, us2 = 0;

    std::cout << std::endl;
    std::cout << "short型数据相加测试结果："
              << std::endl << std::endl;

    ptimer.reset();
    for (i = 0; i < 8; ++i) {
        c[i] = a[i] + b[i];
    }
    us1 = ptimer.nstick();
    std::cout << "仿真结果: " << us1 << " 纳秒" << std::endl;
    ptimer.reset();
    simd_8s_add(ma, mb, mc);
    simd_empty();
    us2 = ptimer.nstick();
    std::cout << "SIMD结果: " << calc_us2(us1, us2) << " 纳秒" << std::endl;
    std::cout << "提升倍率：" << us1 / calc_us2(us1, us2) << std::endl << std::endl;

    std::cout << "SIMD计算结果：" << std::endl;
    std::cout << "    ma：[ ";
    for (i = 0; i < 8; ++i) {
        std::cout << std::setw(5) << (int)ma.s[i];
        if (i < 7) {
            std::cout << ", ";
        }
    }
    std::cout << " ]" << std::endl;
    std::cout << "    mb：[ ";
    for (i = 0; i < 8; ++i) {
        std::cout << std::setw(5) << (int)mb.s[i];
        if (i < 7) {
            std::cout << ", ";
        }
    }
    std::cout << " ]" << std::endl;
    std::cout << "    mc：[ ";
    for (i = 0; i < 8; ++i) {
        std::cout << std::setw(5) << (int)mc.s[i];
        if (i < 7) {
            std::cout << ", ";
        }
    }
    std::cout << " ]" << std::endl;
}

// TEST_BASE_SHORT_MINUS

void test_base_short_minus()
{
    int i = 0;
    char a[8], b[8], c[8];
    simd_m128 ma, mb, mc;

    for (i = 0; i < 8; ++i) {
        ma.c[i] = a[i] = rand() % (0xffff / 8);
        mb.c[i] = b[i] = rand() % (0xffff / 8);
        mc.c[i] = c[i] = 0;
    }

    PreciTimer ptimer;
    long us1, us2 = 0;

    std::cout << std::endl;
    std::cout << "short型数据相减测试结果："
              << std::endl << std::endl;

    ptimer.reset();
    for (i = 0; i < 8; ++i) {
        c[i] = a[i] - b[i];
    }
    us1 = ptimer.nstick();
    std::cout << "仿真结果: " << us1 << " 纳秒" << std::endl;
    ptimer.reset();
    simd_8s_sub(ma, mb, mc);
    simd_empty();
    us2 = ptimer.nstick();
    std::cout << "SIMD结果: " << calc_us2(us1, us2) << " 纳秒" << std::endl;
    std::cout << "提升倍率：" << us1 / calc_us2(us1, us2) << std::endl << std::endl;

    std::cout << "SIMD计算结果：" << std::endl;
    std::cout << "    ma：[ ";
    for (i = 0; i < 8; ++i) {
        std::cout << std::setw(6) << (int)ma.s[i];
        if (i < 7) {
            std::cout << ", ";
        }
    }
    std::cout << " ]" << std::endl;
    std::cout << "    mb：[ ";
    for (i = 0; i < 8; ++i) {
        std::cout << std::setw(6) << (int)mb.s[i];
        if (i < 7) {
            std::cout << ", ";
        }
    }
    std::cout << " ]" << std::endl;
    std::cout << "    mc：[ ";
    for (i = 0; i < 8; ++i) {
        std::cout << std::setw(6) << (int)mc.s[i];
        if (i < 7) {
            std::cout << ", ";
        }
    }
    std::cout << " ]" << std::endl;
}

// TEST_BASE_SHORT_SHFTL

void test_base_short_shftl()
{
    int i = 0;
    short a[8], c[8];
    simd_m128 ma, mc;

    for (i = 0; i < 8; ++i) {
        ma.s[i] = a[i] = rand() % (0xffff / 4);
        mc.s[i] = c[i] = 0;
    }

    PreciTimer ptimer;
    long us1, us2 = 0;

    std::cout << std::endl;
    std::cout << "输入移位位数：";

    std::cin.get(); // 忽略回车符

    int count = 0;
    std::cin >> count;

    std::cout << std::endl << std::endl
              << "short型数据左移测试结果："
              << std::endl << std::endl;

    ptimer.reset();
    for (i = 0; i < 8; ++i) {
        c[i] = a[i] << count;
    }

    us1 = ptimer.nstick();
    std::cout << "仿真结果: " << us1 << " 纳秒" << std::endl;

#ifdef _MSC_VER
    __m64 mcount;
    mcount.m64_i64 = count;
#else
    __m64 mcount = { count, 0 };
#endif
    ptimer.reset();
    simd_8s_shftl(ma, mcount, mc);
    simd_empty();
    us2 = ptimer.nstick();
    std::cout << "SIMD结果: " << calc_us2(us1, us2) << " 纳秒" << std::endl;
    std::cout << "提升倍率：" << us1 / calc_us2(us1, us2) << std::endl << std::endl;

    std::cout << std::setiosflags(std::ios::uppercase) << std::hex;

    std::cout << "SIMD计算结果：" << std::endl;
    std::cout << "    ma：[ ";
    for (i = 0; i < 8; ++i) {
        std::cout << std::setw(4) << std::setfill('0') << ma.s[i];
        if (i < 7) {
            std::cout << ", ";
        }
    }
    std::cout << " ]" << std::endl;
    std::cout << "    mc：[ ";
    for (i = 0; i < 8; ++i) {
        std::cout << std::setw(4) << std::setfill('0') << mc.s[i];
        if (i < 7) {
            std::cout << ", ";
        }
    }
    std::cout << " ]" << std::endl;

    std::cout.unsetf(std::ios::uppercase | std::ios::hex);
    std::cout << std::setfill(' ');
}

// TEST_BASE_SHORT_SHFTR

void test_base_short_shftr()
{
    int i = 0;
    short a[8], c[8];
    simd_m128 ma, mc;

    for (i = 0; i < 8; ++i) {
        ma.s[i] = a[i] = rand() % (0xffff / 4);
        mc.s[i] = c[i] = 0;
    }

    PreciTimer ptimer;
    long us1, us2 = 0;

    std::cout << std::endl;
    std::cout << "输入移位位数：";

    std::cin.get(); // 忽略回车符

    int count = 0;
    std::cin >> count;

    std::cout << std::endl << std::endl
              << "short型数据右移测试结果："
              << std::endl << std::endl;

    ptimer.reset();
    for (i = 0; i < 8; ++i) {
        c[i] = a[i] << count;
    }
    us1 = ptimer.nstick();
    std::cout << "仿真结果: " << us1 << " 纳秒" << std::endl;

#ifdef _MSC_VER
    __m64 mcount;
    mcount.m64_i64 = count;
#else
    __m64 mcount = { count, 0 };
#endif
    ptimer.reset();
    simd_8s_shftr(ma, mcount, mc);
    simd_empty();
    us2 = ptimer.nstick();
    std::cout << "SIMD结果: " << calc_us2(us1, us2) << " 纳秒" << std::endl;
    std::cout << "提升倍率：" << us1 / calc_us2(us1, us2) << std::endl << std::endl;


    std::cout << std::setiosflags(std::ios::uppercase) << std::hex;

    std::cout << "SIMD计算结果：" << std::endl;
    std::cout << "    ma：[ ";
    for (i = 0; i < 8; ++i) {
        std::cout << std::setw(4) << std::setfill('0') << ma.s[i];
        if (i < 7) {
            std::cout << ", ";
        }
    }
    std::cout << " ]" << std::endl;
    std::cout << "    mc：[ ";
    for (i = 0; i < 8; ++i) {
        std::cout << std::setw(4) << std::setfill('0') << mc.s[i];
        if (i < 7) {
            std::cout << ", ";
        }
    }
    std::cout << " ]" << std::endl;

    std::cout.unsetf(std::ios::uppercase | std::ios::hex);
    std::cout << std::setfill(' ');
}

// TEST_BASE_INT_PLUS

void test_base_int_plus()
{
    int i = 0;
    int a[4], b[4], c[4];
    simd_m128 ma, mb, mc;

    for (i = 0; i < 4; ++i) {
        ma.i[i] = a[i] = ((rand() << 16) + rand()) % (0xffffffff / 4);
        mb.i[i] = b[i] = ((rand() << 16) + rand()) % (0xffffffff / 4);
        mc.i[i] = c[i] = 0;
    }

    PreciTimer ptimer;
    long us1, us2 = 0;

    std::cout << std::endl;
    std::cout << "int型数据相加测试结果："
              << std::endl << std::endl;

    ptimer.reset();
    for (i = 0; i < 4; ++i) {
        c[i] = a[i] + b[i];
    }
    us1 = ptimer.nstick();
    std::cout << "仿真结果: " << us1 << " 纳秒" << std::endl;
    ptimer.reset();
    simd_4i_add(ma, mb, mc);
    simd_empty();
    us2 = ptimer.nstick();
    std::cout << "SIMD结果: " << calc_us2(us1, us2) << " 纳秒" << std::endl;
    std::cout << "提升倍率：" << us1 / calc_us2(us1, us2) << std::endl << std::endl;

    std::cout << "SIMD计算结果：" << std::endl;
    std::cout << "    ma：[ ";
    for (i = 0; i < 4; ++i) {
        std::cout << std::setw(10) << (int)ma.i[i];
        if (i < 3) {
            std::cout << ", ";
        }
    }
    std::cout << " ]" << std::endl;
    std::cout << "    mb：[ ";
    for (i = 0; i < 4; ++i) {
        std::cout << std::setw(10) << (int)mb.i[i];
        if (i < 3) {
            std::cout << ", ";
        }
    }
    std::cout << " ]" << std::endl;
    std::cout << "    mc：[ ";
    for (i = 0; i < 4; ++i) {
        std::cout << std::setw(10) << (int)mc.i[i];
        if (i < 3) {
            std::cout << ", ";
        }
    }
    std::cout << " ]" << std::endl;
}

// TEST_BASE_INT_MINUS

void test_base_int_minus()
{
    int i = 0;
    int a[4], b[4], c[4];
    simd_m128 ma, mb, mc;

    for (i = 0; i < 4; ++i) {
        ma.i[i] = a[i] = ((rand() << 16) + rand()) % (0xffffffff / 4);
        mb.i[i] = b[i] = ((rand() << 16) + rand()) % (0xffffffff / 4);
        mc.i[i] = c[i] = 0;
    }

    PreciTimer ptimer;
    long us1, us2 = 0;

    std::cout << std::endl;
    std::cout << "int型数据相减测试结果："
              << std::endl << std::endl;

    ptimer.reset();
    for (i = 0; i < 4; ++i) {
        c[i] = a[i] - b[i];
    }
    us1 = ptimer.nstick();
    std::cout << "仿真结果: " << us1 << " 纳秒" << std::endl;
    ptimer.reset();
    simd_4i_sub(ma, mb, mc);
    simd_empty();
    us2 = ptimer.nstick();
    std::cout << "SIMD结果: " << calc_us2(us1, us2) << " 纳秒" << std::endl;
    std::cout << "提升倍率：" << us1 / calc_us2(us1, us2) << std::endl << std::endl;

    std::cout << "SIMD计算结果：" << std::endl;
    std::cout << "    ma：[ ";
    for (i = 0; i < 4; ++i) {
        std::cout << std::setw(11) << (int)ma.i[i];
        if (i < 3) {
            std::cout << ", ";
        }
    }
    std::cout << " ]" << std::endl;
    std::cout << "    mb：[ ";
    for (i = 0; i < 4; ++i) {
        std::cout << std::setw(11) << (int)mb.i[i];
        if (i < 3) {
            std::cout << ", ";
        }
    }
    std::cout << " ]" << std::endl;
    std::cout << "    mc：[ ";
    for (i = 0; i < 4; ++i) {
        std::cout << std::setw(11) << (int)mc.i[i];
        if (i < 3) {
            std::cout << ", ";
        }
    }
    std::cout << " ]" << std::endl;
}

// TEST_BASE_INT_BAND

void test_base_int_band()
{
    int i = 0;
    int a[4], b[4], c[4];
    simd_m128 ma, mb, mc;

    for (i = 0; i < 4; ++i) {
        ma.i[i] = a[i] = ((rand() << 16) + rand()) % (0xffffffff / 4);
        mb.i[i] = b[i] = ((rand() << 16) + rand()) % (0xffffffff / 4);
        mc.i[i] = c[i] = 0;
    }

    PreciTimer ptimer;
    long us1, us2 = 0;

    std::cout << std::endl;
    std::cout << "int型数据二进制相与测试结果："
              << std::endl << std::endl;

    ptimer.reset();
    for (i = 0; i < 4; ++i) {
        c[i] = a[i] & b[i];
    }
    us1 = ptimer.nstick();
    std::cout << "仿真结果: " << us1 << " 纳秒" << std::endl;
    ptimer.reset();
    simd_4i_band(ma, mb, mc);
    simd_empty();
    us2 = ptimer.nstick();
    std::cout << "SIMD结果: " << calc_us2(us1, us2) << " 纳秒" << std::endl;
    std::cout << "提升倍率：" << us1 / calc_us2(us1, us2) << std::endl << std::endl;


    std::cout << std::setiosflags(std::ios::uppercase) << std::hex;

    std::cout << "SIMD计算结果：" << std::endl;
    std::cout << "    ma：[ ";
    for (i = 0; i < 4; ++i) {
        std::cout << std::setw(8) << std::setfill('0') << ma.i[i];
        if (i < 3) {
            std::cout << ", ";
        }
    }
    std::cout << " ]" << std::endl;
    std::cout << "    mb：[ ";
    for (i = 0; i < 4; ++i) {
        std::cout << std::setw(8) << std::setfill('0') << mb.i[i];
        if (i < 3) {
            std::cout << ", ";
        }
    }
    std::cout << " ]" << std::endl;
    std::cout << "    mc：[ ";
    for (i = 0; i < 4; ++i) {
        std::cout << std::setw(8) << std::setfill('0') << mc.i[i];
        if (i < 3) {
            std::cout << ", ";
        }
    }
    std::cout << " ]" << std::endl;

    std::cout.unsetf(std::ios::uppercase | std::ios::hex);
    std::cout << std::setfill(' ');
}

// TEST_BASE_INT_BOR

void test_base_int_bor()
{
    int i = 0;
    int a[4], b[4], c[4];
    simd_m128 ma, mb, mc;

    for (i = 0; i < 4; ++i) {
        ma.i[i] = a[i] = ((rand() << 16) + rand()) % (0xffffffff / 4);
        mb.i[i] = b[i] = ((rand() << 16) + rand()) % (0xffffffff / 4);
        mc.i[i] = c[i] = 0;
    }

    PreciTimer ptimer;
    long us1, us2 = 0;

    std::cout << std::endl;
    std::cout << "int型数据二进制相或测试结果："
              << std::endl << std::endl;

    ptimer.reset();
    for (i = 0; i < 4; ++i) {
        c[i] = a[i] | b[i];
    }
    us1 = ptimer.nstick();
    std::cout << "仿真结果: " << us1 << " 纳秒" << std::endl;
    ptimer.reset();
    simd_4i_bor(ma, mb, mc);
    simd_empty();
    us2 = ptimer.nstick();
    std::cout << "SIMD结果: " << calc_us2(us1, us2) << " 纳秒" << std::endl;
    std::cout << "提升倍率：" << us1 / calc_us2(us1, us2) << std::endl << std::endl;


    std::cout << std::setiosflags(std::ios::uppercase) << std::hex;

    std::cout << "SIMD计算结果：" << std::endl;
    std::cout << "    ma：[ ";
    for (i = 0; i < 4; ++i) {
        std::cout << std::setw(8) << std::setfill('0') << ma.i[i];
        if (i < 3) {
            std::cout << ", ";
        }
    }
    std::cout << " ]" << std::endl;
    std::cout << "    mb：[ ";
    for (i = 0; i < 4; ++i) {
        std::cout << std::setw(8) << std::setfill('0') << mb.i[i];
        if (i < 3) {
            std::cout << ", ";
        }
    }
    std::cout << " ]" << std::endl;
    std::cout << "    mc：[ ";
    for (i = 0; i < 4; ++i) {
        std::cout << std::setw(8) << std::setfill('0') << mc.i[i];
        if (i < 3) {
            std::cout << ", ";
        }
    }
    std::cout << " ]" << std::endl;

    std::cout.unsetf(std::ios::uppercase | std::ios::hex);
    std::cout << std::setfill(' ');
}

// TEST_BASE_INT_BXOR

void test_base_int_bxor()
{
    int i = 0;
    int a[4], b[4], c[4];
    simd_m128 ma, mb, mc;

    for (i = 0; i < 4; ++i) {
        ma.i[i] = a[i] = ((rand() << 16) + rand()) % (0xffffffff / 4);
        mb.i[i] = b[i] = ((rand() << 16) + rand()) % (0xffffffff / 4);
        mc.i[i] = c[i] = 0;
    }

    PreciTimer ptimer;
    long us1, us2 = 0;

    std::cout << std::endl;
    std::cout << "int型数据二进制异或测试结果："
              << std::endl << std::endl;

    ptimer.reset();
    for (i = 0; i < 4; ++i) {
        c[i] = a[i] | b[i];
    }
    us1 = ptimer.nstick();
    std::cout << "仿真结果: " << us1 << " 纳秒" << std::endl;
    ptimer.reset();
    simd_4i_bxor(ma, mb, mc);
    simd_empty();
    us2 = ptimer.nstick();
    std::cout << "SIMD结果: " << calc_us2(us1, us2) << " 纳秒" << std::endl;
    std::cout << "提升倍率：" << us1 / calc_us2(us1, us2) << std::endl << std::endl;


    std::cout << std::setiosflags(std::ios::uppercase) << std::hex;

    std::cout << "SIMD计算结果：" << std::endl;
    std::cout << "    ma：[ ";
    for (i = 0; i < 4; ++i) {
        std::cout << std::setw(8) << std::setfill('0') << ma.i[i];
        if (i < 3) {
            std::cout << ", ";
        }
    }
    std::cout << " ]" << std::endl;
    std::cout << "    mb：[ ";
    for (i = 0; i < 4; ++i) {
        std::cout << std::setw(8) << std::setfill('0') << mb.i[i];
        if (i < 3) {
            std::cout << ", ";
        }
    }
    std::cout << " ]" << std::endl;
    std::cout << "    mc：[ ";
    for (i = 0; i < 4; ++i) {
        std::cout << std::setw(8) << std::setfill('0') << mc.i[i];
        if (i < 3) {
            std::cout << ", ";
        }
    }
    std::cout << " ]" << std::endl;

    std::cout.unsetf(std::ios::uppercase | std::ios::hex);
    std::cout << std::setfill(' ');
}

// TEST_BASE_INT_SHFTL

void test_base_int_shftl()
{
    int i = 0;
    int a[4], c[4];
    simd_m128 ma, mc;

    for (i = 0; i < 4; ++i) {
        ma.i[i] = a[i] = ((rand() << 16) + rand()) % (0xffffffff / 4);
        mc.s[i] = c[i] = 0;
    }

    PreciTimer ptimer;
    long us1, us2 = 0;

    std::cout << std::endl;
    std::cout << "输入移位位数：";

    std::cin.get(); // 忽略回车符

    int count = 0;
    std::cin >> count;

    std::cout << std::endl << std::endl
              << "int型数据左移测试结果："
              << std::endl << std::endl;

    ptimer.reset();
    for (i = 0; i < 4; ++i) {
        c[i] = a[i] << count;
    }
    us1 = ptimer.nstick();
    std::cout << "仿真结果: " << us1 << " 纳秒" << std::endl;
#ifdef _MSC_VER
    __m64 mcount;
    mcount.m64_i64 = count;
#else
    __m64 mcount = { count, 0 };
#endif
    ptimer.reset();
    simd_4i_shftl(ma, mcount, mc);
    simd_empty();
    us2 = ptimer.nstick();
    std::cout << "SIMD结果: " << calc_us2(us1, us2) << " 纳秒" << std::endl;
    std::cout << "提升倍率：" << us1 / calc_us2(us1, us2) << std::endl << std::endl;


    std::cout << std::setiosflags(std::ios::uppercase) << std::hex;

    std::cout << "SIMD计算结果：" << std::endl;
    std::cout << "    ma：[ ";
    for (i = 0; i < 4; ++i) {
        std::cout << std::setw(8) << std::setfill('0') << ma.i[i];
        if (i < 3) {
            std::cout << ", ";
        }
    }
    std::cout << " ]" << std::endl;
    std::cout << "    mc：[ ";
    for (i = 0; i < 4; ++i) {
        std::cout << std::setw(8) << std::setfill('0') << mc.i[i];
        if (i < 3) {
            std::cout << ", ";
        }
    }
    std::cout << " ]" << std::endl;

    std::cout.unsetf(std::ios::uppercase | std::ios::hex);
    std::cout << std::setfill(' ');
}

// TEST_BASE_INT_SHFTR

void test_base_int_shftr()
{
    int i = 0;
    int a[4], c[4];
    simd_m128 ma, mc;

    for (i = 0; i < 4; ++i) {
        ma.i[i] = a[i] = ((rand() << 16) + rand()) % (0xffffffff / 4);
        mc.s[i] = c[i] = 0;
    }

    PreciTimer ptimer;
    long us1, us2 = 0;

    std::cout << std::endl;
    std::cout << "输入移位位数：";

    std::cin.get(); // 忽略回车符

    int count = 0;
    std::cin >> count;

    std::cout << std::endl << std::endl
              << "int型数据右移测试结果："
              << std::endl << std::endl;

    ptimer.reset();
    for (i = 0; i < 4; ++i) {
        c[i] = a[i] >> count;
    }
    us1 = ptimer.nstick();
    std::cout << "仿真结果: " << us1 << " 纳秒" << std::endl;

#ifdef _MSC_VER
    __m64 mcount;
    mcount.m64_i64 = count;
#else
    __m64 mcount = { count, 0 };
#endif
    ptimer.reset();
    simd_4i_shftr(ma, mcount, mc);
    simd_empty();
    us2 = ptimer.nstick();
    std::cout << "SIMD结果: " << calc_us2(us1, us2) << " 纳秒" << std::endl;
    std::cout << "提升倍率：" << us1 / calc_us2(us1, us2) << std::endl << std::endl;


    std::cout << std::setiosflags(std::ios::uppercase) << std::hex;

    std::cout << "SIMD计算结果：" << std::endl;
    std::cout << "    ma：[ ";
    for (i = 0; i < 4; ++i) {
        std::cout << std::setw(8) << std::setfill('0') << ma.i[i];
        if (i < 3) {
            std::cout << ", ";
        }
    }
    std::cout << " ]" << std::endl;
    std::cout << "    mc：[ ";
    for (i = 0; i < 4; ++i) {
        std::cout << std::setw(8) << std::setfill('0') << mc.i[i];
        if (i < 3) {
            std::cout << ", ";
        }
    }
    std::cout << " ]" << std::endl;

    std::cout.unsetf(std::ios::uppercase | std::ios::hex);
    std::cout << std::setfill(' ');
}

// TEST_BASE_FLOAT_PLUS

void test_base_float_plus()
{
    int i = 0;
    float a[4], b[4], c[4];
    simd_m128 ma, mb, mc;

    for (i = 0; i < 4; ++i) {
        ma.f[i] = a[i] = ((rand() % 200 * (i + 1)) / 1000.f) * (2147483.5f / 4.0f)
                + ((rand() % 10000) / 10000.f);
        mb.f[i] = b[i] = ((rand() % 200 * (i + 1)) / 1000.f) * (2147483.5f / 4.0f)
                + ((rand() % 10000) / 10000.f);
        mc.f[i] = c[i] = 0;
    }

    PreciTimer ptimer;
    long us1, us2 = 0;

    std::cout << std::endl;
    std::cout << "float型数据相加测试结果："
              << std::endl << std::endl;

    ptimer.reset();
    for (i = 0; i < 4; ++i) {
        c[i] = a[i] + b[i];
    }
    us1 = ptimer.nstick();
    std::cout << "仿真结果: " << us1 << " 纳秒" << std::endl;
    ptimer.reset();
    simd_4f_add(ma, mb, mc);
    simd_empty();
    us2 = ptimer.nstick();
    std::cout << "SIMD结果: " << calc_us2(us1, us2) << " 纳秒" << std::endl;
    std::cout << "提升倍率：" << std::setprecision(2)
              << us1 / calc_us2(us1, us2) << std::endl << std::endl;

    std::setiosflags(std::ios::scientific);

    std::cout << "SIMD计算结果：" << std::endl;
    std::cout << "    ma：[ ";
    for (i = 0; i < 4; ++i) {
        std::cout << std::setw(10) << std::setprecision(6) << ma.f[i];
        if (i < 3) {
            std::cout << ", ";
        }
    }
    std::cout << " ]" << std::endl;
    std::cout << "    mb：[ ";
    for (i = 0; i < 4; ++i) {
        std::cout << std::setw(10) << std::setprecision(6) << mb.f[i];
        if (i < 3) {
            std::cout << ", ";
        }
    }
    std::cout << " ]" << std::endl;
    std::cout << "    mc：[ ";
    for (i = 0; i < 4; ++i) {
        std::cout << std::setw(10) << std::setprecision(6) << mc.f[i];
        if (i < 3) {
            std::cout << ", ";
        }
    }
    std::cout << " ]" << std::endl;

    std::cout.unsetf(std::ios::scientific);
}

// TEST_BASE_FLOAT_MINUS

void test_base_float_minus()
{
    int i = 0;
    float a[4], b[4], c[4];
    simd_m128 ma, mb, mc;

    for (i = 0; i < 4; ++i) {
        ma.f[i] = a[i] = ((rand() % 200 * (i + 1)) / 1000.f) * (2147483.5f / 4.0f)
                + ((rand() % 10000) / 10000.f);
        mb.f[i] = b[i] = ((rand() % 200 * (i + 1)) / 1000.f) * (2147483.5f / 4.0f)
                + ((rand() % 10000) / 10000.f);
        mc.f[i] = c[i] = 0;
    }

    PreciTimer ptimer;
    long us1, us2 = 0;

    std::cout << std::endl;
    std::cout << "float型数据相减测试结果："
              << std::endl << std::endl;

    ptimer.reset();
    for (i = 0; i < 4; ++i) {
        c[i] = a[i] - b[i];
    }
    us1 = ptimer.nstick();
    std::cout << "仿真结果: " << us1 << " 纳秒" << std::endl;
    ptimer.reset();
    simd_4f_sub(ma, mb, mc);
    us2 = ptimer.nstick();
    std::cout << "SIMD结果: " << calc_us2(us1, us2) << " 纳秒" << std::endl;
    std::cout << "提升倍率：" << std::setprecision(2)
              << us1 / calc_us2(us1, us2) << std::endl << std::endl;

    std::setiosflags(std::ios::scientific);

    std::cout << "SIMD计算结果：" << std::endl;
    std::cout << "    ma：[ ";
    for (i = 0; i < 4; ++i) {
        std::cout << std::setw(11) << std::setprecision(6) << ma.f[i];
        if (i < 3) {
            std::cout << ", ";
        }
    }
    std::cout << " ]" << std::endl;
    std::cout << "    mb：[ ";
    for (i = 0; i < 4; ++i) {
        std::cout << std::setw(11) << std::setprecision(6) << mb.f[i];
        if (i < 3) {
            std::cout << ", ";
        }
    }
    std::cout << " ]" << std::endl;
    std::cout << "    mc：[ ";
    for (i = 0; i < 4; ++i) {
        std::cout << std::setw(11) << std::setprecision(6) << mc.f[i];
        if (i < 3) {
            std::cout << ", ";
        }
    }
    std::cout << " ]" << std::endl;

    std::cout.unsetf(std::ios::scientific);
}

// TEST_BASE_FLOAT_MUL

void test_base_float_mul()
{
    int i = 0;
    float a[4], b[4], c[4];
    simd_m128 ma, mb, mc;

    for (i = 0; i < 4; ++i) {
        ma.f[i] = a[i] = ((rand() % 200 * (i + 1)) / 1000.f) * 46340.95f
                + ((rand() % 10000) / 10000.f);
        mb.f[i] = b[i] = ((rand() % 200 * (i + 1)) / 1000.f) * 46340.95f
                + ((rand() % 10000) / 10000.f);
        mc.f[i] = c[i] = 0;
    }

    PreciTimer ptimer;
    long us1, us2 = 0;

    std::cout << std::endl;
    std::cout << "float型数据相乘测试结果："
              << std::endl << std::endl;

    ptimer.reset();
    for (i = 0; i < 4; ++i) {
        c[i] = a[i] * b[i];
    }
    us1 = ptimer.nstick();
    std::cout << "仿真结果: " << us1 << " 纳秒" << std::endl;
    ptimer.reset();
    simd_4f_mul(ma, mb, mc);
    us2 = ptimer.nstick();
    std::cout << "SIMD结果: " << calc_us2(us1, us2) << " 纳秒" << std::endl;
    std::cout << "提升倍率：" << std::setprecision(2)
              << us1 / calc_us2(us1, us2) << std::endl << std::endl;

    std::setiosflags(std::ios::scientific);

    std::cout << "SIMD计算结果：" << std::endl;
    std::cout << "    ma：[ ";
    for (i = 0; i < 4; ++i) {
        std::cout << std::setw(15) << std::setprecision(6) << ma.f[i];
        if (i < 3) {
            std::cout << ", ";
        }
    }
    std::cout << " ]" << std::endl;
    std::cout << "    mb：[ ";
    for (i = 0; i < 4; ++i) {
        std::cout << std::setw(15) << std::setprecision(6) << mb.f[i];
        if (i < 3) {
            std::cout << ", ";
        }
    }
    std::cout << " ]" << std::endl;
    std::cout << "    mc：[ ";
    for (i = 0; i < 4; ++i) {
        std::cout << std::setw(15) << std::setprecision(6) << mc.f[i];
        if (i < 3) {
            std::cout << ", ";
        }
    }
    std::cout << " ]" << std::endl;

    std::cout.unsetf(std::ios::scientific);
}

// TEST_BASE_FLOAT_DIV

void test_base_float_div()
{
    int i = 0;
    float a[4], b[4], c[4];
    simd_m128 ma, mb, mc;

    for (i = 0; i < 4; ++i) {
        ma.f[i] = a[i] = ((rand() % 200 * (i + 1)) / 1000.f) * 46340.95f
                + ((rand() % 10000) / 10000.f);
        mb.f[i] = b[i] = ((rand() % 200 * (i + 1)) / 1000.f) * 46340.95f
                + ((rand() % 10000) / 10000.f);
        mc.f[i] = c[i] = 0;
    }

    PreciTimer ptimer;
    long us1, us2 = 0;

    std::cout << std::endl;
    std::cout << "float型数据相除测试结果："
              << std::endl << std::endl;

    ptimer.reset();
    for (i = 0; i < 4; ++i) {
        c[i] = a[i] / b[i];
    }
    us1 = ptimer.nstick();
    std::cout << "仿真结果: " << us1 << " 纳秒" << std::endl;
    ptimer.reset();
    simd_4f_div(ma, mb, mc);
    us2 = ptimer.nstick();
    std::cout << "SIMD结果: " << calc_us2(us1, us2) << " 纳秒" << std::endl;
    std::cout << "提升倍率：" << std::setprecision(2)
              << us1 / calc_us2(us1, us2) << std::endl << std::endl;

    std::setiosflags(std::ios::scientific);

    std::cout << "SIMD计算结果：" << std::endl;
    std::cout << "    ma：[ ";
    for (i = 0; i < 4; ++i) {
        std::cout << std::setw(16) << std::setprecision(6) << ma.f[i];
        if (i < 3) {
            std::cout << ", ";
        }
    }
    std::cout << " ]" << std::endl;
    std::cout << "    mb：[ ";
    for (i = 0; i < 4; ++i) {
        std::cout << std::setw(16) << std::setprecision(6) << mb.f[i];
        if (i < 3) {
            std::cout << ", ";
        }
    }
    std::cout << " ]" << std::endl;
    std::cout << "    mc：[ ";
    for (i = 0; i < 4; ++i) {
        std::cout << std::setw(16) << std::setprecision(6) << mc.f[i];
        if (i < 3) {
            std::cout << ", ";
        }
    }
    std::cout << " ]" << std::endl;

    std::cout.unsetf(std::ios::scientific);
}

// TEST_BASE_FLOAT_SQRT

void test_base_float_sqrt()
{
    int i = 0;
    float a[4], c[4];
    simd_m128 ma, mc;

    for (i = 0; i < 4; ++i) {
        ma.f[i] = a[i] = float((i + 1) * (i + 1) * (i + 1) * (i + 1));
        mc.f[i] = c[i] = 0;
    }

    PreciTimer ptimer;
    long us1, us2 = 0;

    std::cout << std::endl;
    std::cout << "float型数据开平方测试结果："
              << std::endl << std::endl;

    ptimer.reset();
    for (i = 0; i < 4; ++i) {
        c[i] = sqrt(a[i]);
    }
    us1 = ptimer.nstick();
    std::cout << "仿真结果: " << us1 << " 纳秒" << std::endl;
    ptimer.reset();
    simd_4f_sqrt(ma, mc);
    us2 = ptimer.nstick();
    std::cout << "SIMD结果: " << calc_us2(us1, us2) << " 纳秒" << std::endl;
    std::cout << "提升倍率：" << std::setprecision(2)
              << us1 / calc_us2(us1, us2) << std::endl << std::endl;

    std::setiosflags(std::ios::scientific);

    std::cout << "SIMD计算结果：" << std::endl;
    std::cout << "    ma：[ ";
    for (i = 0; i < 4; ++i) {
        std::cout << std::setw(15) << std::setprecision(6) << ma.f[i];
        if (i < 3) {
            std::cout << ", ";
        }
    }
    std::cout << " ]" << std::endl;
    std::cout << "    mc：[ ";
    for (i = 0; i < 4; ++i) {
        std::cout << std::setw(15) << std::setprecision(6) << mc.f[i];
        if (i < 3) {
            std::cout << ", ";
        }
    }
    std::cout << " ]" << std::endl;

    std::cout.unsetf(std::ios::scientific);
}

// TEST_BASE_FLOAT_RCP

void test_base_float_rcp()
{
    int i = 0;
    float a[4], c[4];
    simd_m128 ma, mc;

    for (i = 0; i < 4; ++i) {
        ma.f[i] = a[i] = ((rand() % 200 * (i + 1)) / 1000.f) * (2147483.5f / 4.0f)
                + ((rand() % 10000) / 10000.f);
        mc.f[i] = c[i] = 0;
    }

    PreciTimer ptimer;
    long us1, us2 = 0;

    std::cout << std::endl;
    std::cout << "float型数据取倒数测试结果："
              << std::endl << std::endl;

    ptimer.reset();
    for (i = 0; i < 4; ++i) {
        c[i] = 1 / a[i];
    }
    us1 = ptimer.nstick();
    std::cout << "仿真结果: " << us1 << " 纳秒" << std::endl;
    ptimer.reset();
    simd_4f_rcp(ma, mc);
    us2 = ptimer.nstick();
    std::cout << "SIMD结果: " << calc_us2(us1, us2) << " 纳秒" << std::endl;
    std::cout << "提升倍率：" << std::setprecision(2)
              << us1 / calc_us2(us1, us2) << std::endl << std::endl;

    std::setiosflags(std::ios::scientific);

    std::cout << "SIMD计算结果：" << std::endl;
    std::cout << "    ma：[ ";
    for (i = 0; i < 4; ++i) {
        std::cout << std::setw(16) << std::setprecision(6) << ma.f[i];
        if (i < 3) {
            std::cout << ", ";
        }
    }
    std::cout << " ]" << std::endl;
    std::cout << "    mc：[ ";
    for (i = 0; i < 4; ++i) {
        std::cout << std::setw(16) << std::setprecision(6) << mc.f[i];
        if (i < 3) {
            std::cout << ", ";
        }
    }
    std::cout << " ]" << std::endl;

    std::cout.unsetf(std::ios::scientific);
}

// TEST_BASE_FLOAT_MIN

void test_base_float_min()
{
    int i = 0;
    float a[4], b[4], c[4];
    simd_m128 ma, mb, mc;

    for (i = 0; i < 4; ++i) {
        ma.f[i] = a[i] = ((rand() % 200 * (i + 1)) / 1000.f) * (2147483.5f / 4.0f)
                + ((rand() % 10000) / 10000.f);
        mb.f[i] = b[i] = ((rand() % 200 * (i + 1)) / 1000.f) * (2147483.5f / 4.0f)
                + ((rand() % 10000) / 10000.f);
        mc.f[i] = c[i] = 0;
    }

    PreciTimer ptimer;
    long us1, us2 = 0;

    std::cout << std::endl;
    std::cout << "float型数据取最小值测试结果："
              << std::endl << std::endl;

    ptimer.reset();
    for (i = 0; i < 4; ++i) {
        c[i] = min(a[i], b[i]);
    }
    us1 = ptimer.nstick();
    std::cout << "仿真结果: " << us1 << " 纳秒" << std::endl;
    ptimer.reset();
    simd_4f_min(ma, mb, mc);
    us2 = ptimer.nstick();
    std::cout << "SIMD结果: " << calc_us2(us1, us2) << " 纳秒" << std::endl;
    std::cout << "提升倍率：" << std::setprecision(2)
              << us1 / calc_us2(us1, us2) << std::endl << std::endl;

    std::setiosflags(std::ios::scientific);

    std::cout << "SIMD计算结果：" << std::endl;
    std::cout << "    ma：[ ";
    for (i = 0; i < 4; ++i) {
        std::cout << std::setw(15) << std::setprecision(6) << ma.f[i];
        if (i < 3) {
            std::cout << ", ";
        }
    }
    std::cout << " ]" << std::endl;
    std::cout << "    mb：[ ";
    for (i = 0; i < 4; ++i) {
        std::cout << std::setw(15) << std::setprecision(6) << mb.f[i];
        if (i < 3) {
            std::cout << ", ";
        }
    }
    std::cout << " ]" << std::endl;
    std::cout << "    mc：[ ";
    for (i = 0; i < 4; ++i) {
        std::cout << std::setw(15) << std::setprecision(6) << mc.f[i];
        if (i < 3) {
            std::cout << ", ";
        }
    }
    std::cout << " ]" << std::endl;

    std::cout.unsetf(std::ios::scientific);
}

// TEST_BASE_FLOAT_MAX

void test_base_float_max()
{
    int i = 0;
    float a[4], b[4], c[4];
    simd_m128 ma, mb, mc;

    for (i = 0; i < 4; ++i) {
        ma.f[i] = a[i] = ((rand() % 200 * (i + 1)) / 1000.f) * (2147483.5f / 4.0f)
                + ((rand() % 10000) / 10000.f);
        mb.f[i] = b[i] = ((rand() % 200 * (i + 1)) / 1000.f) * (2147483.5f / 4.0f)
                + ((rand() % 10000) / 10000.f);
        mc.f[i] = c[i] = 0;
    }

    PreciTimer ptimer;
    long us1, us2 = 0;

    std::cout << std::endl;
    std::cout << "float型数据取最大值测试结果："
              << std::endl << std::endl;

    ptimer.reset();
    for (i = 0; i < 4; ++i) {
        c[i] = max(a[i], b[i]);
    }
    us1 = ptimer.nstick();
    std::cout << "仿真结果: " << us1 << " 纳秒" << std::endl;
    ptimer.reset();
    simd_4f_max(ma, mb, mc);
    us2 = ptimer.nstick();
    std::cout << "SIMD结果: " << calc_us2(us1, us2) << " 纳秒" << std::endl;
    std::cout << "提升倍率：" << std::setprecision(2)
              << us1 / calc_us2(us1, us2) << std::endl << std::endl;

    std::setiosflags(std::ios::scientific);

    std::cout << "SIMD计算结果：" << std::endl;
    std::cout << "    ma：[ ";
    for (i = 0; i < 4; ++i) {
        std::cout << std::setw(16) << std::setprecision(6) << ma.f[i];
        if (i < 3) {
            std::cout << ", ";
        }
    }
    std::cout << " ]" << std::endl;
    std::cout << "    mb：[ ";
    for (i = 0; i < 4; ++i) {
        std::cout << std::setw(16) << std::setprecision(4) << mb.f[i];
        if (i < 3) {
            std::cout << ", ";
        }
    }
    std::cout << " ]" << std::endl;
    std::cout << "    mc：[ ";
    for (i = 0; i < 4; ++i) {
        std::cout << std::setw(16) << std::setprecision(6) << mc.f[i];
        if (i < 3) {
            std::cout << ", ";
        }
    }
    std::cout << " ]" << std::endl;

    std::cout.unsetf(std::ios::scientific);
}

// TEST_BASE_FLOAT_EQ

void test_base_float_eq()
{
    int i = 0;
    float a[4], b[4], c[4];
    simd_m128 ma, mb, mc;

    for (i = 0; i < 4; ++i) {
        ma.f[i] = a[i] = ((rand() % 200 * (i + 1)) / 1000.f) * (2147483.5f / 4.0f)
                + ((rand() % 10000) / 10000.f);
        mb.f[i] = b[i] = ((rand() % 200 * (i + 1)) / 1000.f) * (2147483.5f / 4.0f)
                + ((rand() % 10000) / 10000.f);
        mc.f[i] = c[i] = 0;
    }

    PreciTimer ptimer;
    long us1, us2 = 0;

    std::cout << std::endl;
    std::cout << "float型数据相等测试结果："
              << std::endl << std::endl;

    ptimer.reset();
    for (i = 0; i < 4; ++i) {
        c[i] = a[i] == b[i];
    }
    us1 = ptimer.nstick();
    std::cout << "仿真结果: " << us1 << " 纳秒" << std::endl;
    ptimer.reset();
    simd_4f_meq(ma, mb, mc);
    us2 = ptimer.nstick();
    std::cout << "SIMD结果: " << calc_us2(us1, us2) << " 纳秒" << std::endl;
    std::cout << "提升倍率：" << std::setprecision(2)
              << us1 / calc_us2(us1, us2) << std::endl << std::endl;

    std::setiosflags(std::ios::scientific);

    std::cout << "SIMD计算结果：" << std::endl;
    std::cout << "    ma：[ ";
    for (i = 0; i < 4; ++i) {
        std::cout << std::setw(15) << std::setprecision(6) << ma.f[i];
        if (i < 3) {
            std::cout << ", ";
        }
    }
    std::cout << " ]" << std::endl;
    std::cout << "    mb：[ ";
    for (i = 0; i < 4; ++i) {
        std::cout << std::setw(15) << std::setprecision(6) << mb.f[i];
        if (i < 3) {
            std::cout << ", ";
        }
    }
    std::cout << " ]" << std::endl;
    std::cout << "    mc：[ ";
    for (i = 0; i < 4; ++i) {
        std::cout << std::setw(15) << std::setprecision(6) << mc.f[i];
        if (i < 3) {
            std::cout << ", ";
        }
    }
    std::cout << " ]" << std::endl;

    std::cout.unsetf(std::ios::scientific);
}

// TEST_BASE_FLOAT_NEQ

void test_base_float_neq()
{
    int i = 0;
    float a[4], b[4], c[4];
    simd_m128 ma, mb, mc;

    for (i = 0; i < 4; ++i) {
        ma.f[i] = a[i] = ((rand() % 200 * (i + 1)) / 1000.f) * (2147483.5f / 4.0f)
                + ((rand() % 10000) / 10000.f);
        mb.f[i] = b[i] = ((rand() % 200 * (i + 1)) / 1000.f) * (2147483.5f / 4.0f)
                + ((rand() % 10000) / 10000.f);
        mc.f[i] = c[i] = 0;
    }

    PreciTimer ptimer;
    long us1, us2 = 0;

    std::cout << std::endl;
    std::cout << "float型数据不相等测试结果："
              << std::endl << std::endl;

    ptimer.reset();
    for (i = 0; i < 4; ++i) {
        c[i] = a[i] != b[i];
    }
    us1 = ptimer.nstick();
    std::cout << "仿真结果: " << us1 << " 纳秒" << std::endl;
    ptimer.reset();
    simd_4f_mneq(ma, mb, mc);
    us2 = ptimer.nstick();
    std::cout << "SIMD结果: " << calc_us2(us1, us2) << " 纳秒" << std::endl;
    std::cout << "提升倍率：" << std::setprecision(2)
              << us1 / calc_us2(us1, us2) << std::endl << std::endl;

    std::setiosflags(std::ios::scientific);

    std::cout << "SIMD计算结果：" << std::endl;
    std::cout << "    ma：[ ";
    for (i = 0; i < 4; ++i) {
        std::cout << std::setw(16) << std::setprecision(6) << ma.f[i];
        if (i < 3) {
            std::cout << ", ";
        }
    }
    std::cout << " ]" << std::endl;
    std::cout << "    mb：[ ";
    for (i = 0; i < 4; ++i) {
        std::cout << std::setw(16) << std::setprecision(6) << mb.f[i];
        if (i < 3) {
            std::cout << ", ";
        }
    }
    std::cout << " ]" << std::endl;
    std::cout << "    mc：[ ";
    for (i = 0; i < 4; ++i) {
        std::cout << std::setw(16) << std::setprecision(6) << mc.f[i];
        if (i < 3) {
            std::cout << ", ";
        }
    }
    std::cout << " ]" << std::endl;

    std::cout.unsetf(std::ios::scientific);
}

// TEST_BASE_FLOAT_LT

void test_base_float_lt()
{
    int i = 0;
    float a[4], b[4], c[4];
    simd_m128 ma, mb, mc;

    for (i = 0; i < 4; ++i) {
        ma.f[i] = a[i] = ((rand() % 200 * (i + 1)) / 1000.f) * (2147483.5f / 4.0f)
                + ((rand() % 10000) / 10000.f);
        mb.f[i] = b[i] = ((rand() % 200 * (i + 1)) / 1000.f) * (2147483.5f / 4.0f)
                + ((rand() % 10000) / 10000.f);
        mc.f[i] = c[i] = 0;
    }

    PreciTimer ptimer;
    long us1, us2 = 0;

    std::cout << std::endl;
    std::cout << "float型数据小于测试结果："
              << std::endl << std::endl;

    ptimer.reset();
    for (i = 0; i < 4; ++i) {
        c[i] = a[i] < b[i];
    }
    us1 = ptimer.nstick();
    std::cout << "仿真结果: " << us1 << " 纳秒" << std::endl;
    ptimer.reset();
    simd_4f_mlt(ma, mb, mc);
    us2 = ptimer.nstick();
    std::cout << "SIMD结果: " << calc_us2(us1, us2) << " 纳秒" << std::endl;
    std::cout << "提升倍率：" << std::setprecision(2)
              << us1 / calc_us2(us1, us2) << std::endl << std::endl;

    std::setiosflags(std::ios::scientific);

    std::cout << "SIMD计算结果：" << std::endl;
    std::cout << "    ma：[ ";
    for (i = 0; i < 4; ++i) {
        std::cout << std::setw(15) << std::setprecision(6) << ma.f[i];
        if (i < 3) {
            std::cout << ", ";
        }
    }
    std::cout << " ]" << std::endl;
    std::cout << "    mb：[ ";
    for (i = 0; i < 4; ++i) {
        std::cout << std::setw(15) << std::setprecision(6) << mb.f[i];
        if (i < 3) {
            std::cout << ", ";
        }
    }
    std::cout << " ]" << std::endl;
    std::cout << "    mc：[ ";
    for (i = 0; i < 4; ++i) {
        std::cout << std::setw(15) << std::setprecision(6) << mc.f[i];
        if (i < 3) {
            std::cout << ", ";
        }
    }
    std::cout << " ]" << std::endl;

    std::cout.unsetf(std::ios::scientific);
}

// TEST_BASE_FLOAT_GT

void test_base_float_gt()
{
    int i = 0;
    float a[4], b[4], c[4];
    simd_m128 ma, mb, mc;

    for (i = 0; i < 4; ++i) {
        ma.f[i] = a[i] = ((rand() % 200 * (i + 1)) / 1000.f) * (2147483.5f / 4.0f)
                + ((rand() % 10000) / 10000.f);
        mb.f[i] = b[i] = ((rand() % 200 * (i + 1)) / 1000.f) * (2147483.5f / 4.0f)
                + ((rand() % 10000) / 10000.f);
        mc.f[i] = c[i] = 0;
    }

    PreciTimer ptimer;
    long us1, us2 = 0;

    std::cout << std::endl;
    std::cout << "float型数据大于测试结果："
              << std::endl << std::endl;

    ptimer.reset();
    for (i = 0; i < 4; ++i) {
        c[i] = a[i] > b[i];
    }
    us1 = ptimer.nstick();
    std::cout << "仿真结果: " << us1 << " 纳秒" << std::endl;
    ptimer.reset();
    simd_4f_mgt(ma, mb, mc);
    us2 = ptimer.nstick();
    std::cout << "SIMD结果: " << calc_us2(us1, us2) << " 纳秒" << std::endl;
    std::cout << "提升倍率：" << std::setprecision(2)
              << us1 / calc_us2(us1, us2) << std::endl << std::endl;

    std::setiosflags(std::ios::scientific);

    std::cout << "SIMD计算结果：" << std::endl;
    std::cout << "    ma：[ ";
    for (i = 0; i < 4; ++i) {
        std::cout << std::setw(16) << std::setprecision(6) << ma.f[i];
        if (i < 3) {
            std::cout << ", ";
        }
    }
    std::cout << " ]" << std::endl;
    std::cout << "    mb：[ ";
    for (i = 0; i < 4; ++i) {
        std::cout << std::setw(16) << std::setprecision(6) << mb.f[i];
        if (i < 3) {
            std::cout << ", ";
        }
    }
    std::cout << " ]" << std::endl;
    std::cout << "    mc：[ ";
    for (i = 0; i < 4; ++i) {
        std::cout << std::setw(16) << std::setprecision(6) << mc.f[i];
        if (i < 3) {
            std::cout << ", ";
        }
    }
    std::cout << " ]" << std::endl;

    std::cout.unsetf(std::ios::scientific);
}

// TEST_BASE_FLOAT_LE

void test_base_float_le()
{
    int i = 0;
    float a[4], b[4], c[4];
    simd_m128 ma, mb, mc;

    for (i = 0; i < 4; ++i) {
        ma.f[i] = a[i] = ((rand() % 200 * (i + 1)) / 1000.f) * (2147483.5f / 4.0f)
                + ((rand() % 10000) / 10000.f);
        mb.f[i] = b[i] = ((rand() % 200 * (i + 1)) / 1000.f) * (2147483.5f / 4.0f)
                + ((rand() % 10000) / 10000.f);
        mc.f[i] = c[i] = 0;
    }

    PreciTimer ptimer;
    long us1, us2 = 0;

    std::cout << std::endl;
    std::cout << "float型数据小等于测试结果："
              << std::endl << std::endl;

    ptimer.reset();
    for (i = 0; i < 4; ++i) {
        c[i] = a[i] <= b[i];
    }
    us1 = ptimer.nstick();
    std::cout << "仿真结果: " << us1 << " 纳秒" << std::endl;
    ptimer.reset();
    simd_4f_mle(ma, mb, mc);
    us2 = ptimer.nstick();
    std::cout << "SIMD结果: " << calc_us2(us1, us2) << " 纳秒" << std::endl;
    std::cout << "提升倍率：" << std::setprecision(2)
              << us1 / calc_us2(us1, us2) << std::endl << std::endl;

    std::setiosflags(std::ios::scientific);

    std::cout << "SIMD计算结果：" << std::endl;
    std::cout << "    ma：[ ";
    for (i = 0; i < 4; ++i) {
        std::cout << std::setw(15) << std::setprecision(6) << ma.f[i];
        if (i < 3) {
            std::cout << ", ";
        }
    }
    std::cout << " ]" << std::endl;
    std::cout << "    mb：[ ";
    for (i = 0; i < 4; ++i) {
        std::cout << std::setw(15) << std::setprecision(6) << mb.f[i];
        if (i < 3) {
            std::cout << ", ";
        }
    }
    std::cout << " ]" << std::endl;
    std::cout << "    mc：[ ";
    for (i = 0; i < 4; ++i) {
        std::cout << std::setw(15) << std::setprecision(6) << mc.f[i];
        if (i < 3) {
            std::cout << ", ";
        }
    }
    std::cout << " ]" << std::endl;

    std::cout.unsetf(std::ios::scientific);
}

// TEST_BASE_FLOAT_GE

void test_base_float_ge()
{
    int i = 0;
    float a[4], b[4], c[4];
    simd_m128 ma, mb, mc;

    for (i = 0; i < 4; ++i) {
        ma.f[i] = a[i] = ((rand() % 200 * (i + 1)) / 1000.f) * (2147483.5f / 4.0f)
                + ((rand() % 10000) / 10000.f);
        mb.f[i] = b[i] = ((rand() % 200 * (i + 1)) / 1000.f) * (2147483.5f / 4.0f)
                + ((rand() % 10000) / 10000.f);
        mc.f[i] = c[i] = 0;
    }

    PreciTimer ptimer;
    long us1, us2 = 0;

    std::cout << std::endl;
    std::cout << "float型数据大等于测试结果："
              << std::endl << std::endl;

    ptimer.reset();
    for (i = 0; i < 4; ++i) {
        c[i] = a[i] > b[i];
    }
    us1 = ptimer.nstick();
    std::cout << "仿真结果: " << us1 << " 纳秒" << std::endl;
    ptimer.reset();
    simd_4f_mge(ma, mb, mc);
    us2 = ptimer.nstick();
    std::cout << "SIMD结果: " << calc_us2(us1, us2) << " 纳秒" << std::endl;
    std::cout << "提升倍率：" << std::setprecision(2)
              << us1 / calc_us2(us1, us2) << std::endl << std::endl;

    std::setiosflags(std::ios::scientific);

    std::cout << "SIMD计算结果：" << std::endl;
    std::cout << "    ma：[ ";
    for (i = 0; i < 4; ++i) {
        std::cout << std::setw(16) << std::setprecision(6) << ma.f[i];
        if (i < 3) {
            std::cout << ", ";
        }
    }
    std::cout << " ]" << std::endl;
    std::cout << "    mb：[ ";
    for (i = 0; i < 4; ++i) {
        std::cout << std::setw(16) << std::setprecision(6) << mb.f[i];
        if (i < 3) {
            std::cout << ", ";
        }
    }
    std::cout << " ]" << std::endl;
    std::cout << "    mc：[ ";
    for (i = 0; i < 4; ++i) {
        std::cout << std::setw(16) << std::setprecision(6) << mc.f[i];
        if (i < 3) {
            std::cout << ", ";
        }
    }
    std::cout << " ]" << std::endl;

    std::cout.unsetf(std::ios::scientific);
}

// TEST_CHAR_PLUS

void _emu_char_plus(const char a[], const char b[], char c[], int length)
{
    const char *pa = a;
    const char *pb = b;
    char *pc = c;
    while (length-- > 0) {
        *pc++ = *pa++ + *pb++;
    }
}

void test_char_plus(void)
{
    char *a = new char[ARRAY_COUNT];
    char *b = new char[ARRAY_COUNT];
    char *c = new char[ARRAY_COUNT];
    memset(a, 0, ARRAY_COUNT * sizeof(char));
    memset(b, 0, ARRAY_COUNT * sizeof(char));
    memset(c, 0, ARRAY_COUNT * sizeof(char));

    for (int i = 0; i < ARRAY_COUNT; ++i) {
        a[i] = (-i);
        b[i] = (-i - 1);
    }

    PreciTimer ptimer;
    long us1, us2 = 0;

    std::cout << std::endl;
    std::cout << "char型矢量相加测试结果：" << std::endl << std::endl;

    ptimer.reset();
    _emu_char_plus(a, b, c, ARRAY_COUNT);
    us1 = ptimer.ustick();
    std::cout << "仿真结果: " << us1 << " 微秒" << std::endl;
    ptimer.reset();
    JSimdVector::plus(a, b, c, ARRAY_COUNT);
    us2 = ptimer.ustick();
    std::cout << "SIMD结果: " << us2 << " 微秒" << std::endl;
    std::cout << "提升倍率：" << us1 / calc_us2(us1, us2) << std::endl << std::endl;

    for (int i = 0; i < ARRAY_COUNT; ++i) {
        if (c[i] != char(a[i] + b[i])) {
            assert(false);
        }
    }

    delete[] a;
    delete[] b;
    delete[] c;
}

// TEST_CHAR_MINUS

void _emu_char_minus(const char a[], const char b[], char c[], int length)
{
    const char *pa = a;
    const char *pb = b;
    char *pc = c;
    while (length-- > 0) {
        *pc++ = *pa++ - *pb++;
    }
}

void test_char_minus(void)
{
    char *a = new char[ARRAY_COUNT];
    char *b = new char[ARRAY_COUNT];
    char *c = new char[ARRAY_COUNT];
    memset(a, 0, ARRAY_COUNT * sizeof(char));
    memset(b, 0, ARRAY_COUNT * sizeof(char));
    memset(c, 0, ARRAY_COUNT * sizeof(char));

    for (int i = 0; i < ARRAY_COUNT; ++i) {
        a[i] = -i - 5;
        b[i] = -i - 2;
    }

    PreciTimer ptimer;
    long us1, us2 = 0;

    std::cout << std::endl;
    std::cout << "char型矢量相减测试结果：" << std::endl << std::endl;

    ptimer.reset();
    _emu_char_minus(a, b, c, ARRAY_COUNT);
    us1 = ptimer.ustick();
    std::cout << "仿真结果: " << us1 << " 微秒" << std::endl;
    ptimer.reset();
    JSimdVector::minus(a, b, c, ARRAY_COUNT);
    us2 = ptimer.ustick();
    std::cout << "SIMD结果: " << us2 << " 微秒" << std::endl;
    std::cout << "提升倍率：" << us1 / calc_us2(us1, us2) << std::endl << std::endl;

    delete[] a;
    delete[] b;
    delete[] c;
}

// TEST_SHORT_PLUS

void _emu_short_plus(const short a[], const short b[], short c[], int length)
{
    const short *pa = a;
    const short *pb = b;
    short *pc = c;
    while (length-- > 0) {
        *pc++ = *pa++ + *pb++;
    }
}

void test_short_plus(void)
{
    short *a = new short[ARRAY_COUNT];
    short *b = new short[ARRAY_COUNT];
    short *c = new short[ARRAY_COUNT];
    memset(a, 0, ARRAY_COUNT * sizeof(short));
    memset(b, 0, ARRAY_COUNT * sizeof(short));
    memset(c, 0, ARRAY_COUNT * sizeof(short));

    for (int i = 0; i < ARRAY_COUNT; ++i) {
        a[i] = -i;
        b[i] = -i - 1;
    }

    PreciTimer ptimer;
    long us1, us2 = 0;

    std::cout << std::endl;
    std::cout << "short型矢量相加测试结果：" << std::endl << std::endl;

    ptimer.reset();
    _emu_short_plus(a, b, c, ARRAY_COUNT);
    us1 = ptimer.ustick();
    std::cout << "仿真结果: " << us1 << " 微秒" << std::endl;
    ptimer.reset();
    JSimdVector::plus(a, b, c, ARRAY_COUNT);
    us2 = ptimer.ustick();
    std::cout << "SIMD结果: " << us2 << " 微秒" << std::endl;
    std::cout << "提升倍率：" << us1 / calc_us2(us1, us2) << std::endl << std::endl;

    delete[] a;
    delete[] b;
    delete[] c;
}

// TEST_SHORT_MINUS

void _emu_short_minus(const short a[], const short b[], short c[], int length)
{
    const short *pa = a;
    const short *pb = b;
    short *pc = c;
    while (length-- > 0) {
        *pc++ = *pa++ - *pb++;
    }
}

void test_short_minus(void)
{
    short *a = new short[ARRAY_COUNT];
    short *b = new short[ARRAY_COUNT];
    short *c = new short[ARRAY_COUNT];
    memset(a, 0, ARRAY_COUNT * sizeof(short));
    memset(b, 0, ARRAY_COUNT * sizeof(short));
    memset(c, 0, ARRAY_COUNT * sizeof(short));

    for (int i = 0; i < ARRAY_COUNT; ++i) {
        a[i] = -i;
        b[i] = -i - 1;
    }

    PreciTimer ptimer;
    long us1, us2 = 0;

    std::cout << std::endl;
    std::cout << "short型矢量相减测试结果：" << std::endl << std::endl;

    ptimer.reset();
    _emu_short_minus(a, b, c, ARRAY_COUNT);
    us1 = ptimer.ustick();
    std::cout << "仿真结果: " << us1 << " 微秒" << std::endl;
    ptimer.reset();
    JSimdVector::minus(a, b, c, ARRAY_COUNT);
    us2 = ptimer.ustick();
    std::cout << "SIMD结果: " << us2 << " 微秒" << std::endl;
    std::cout << "提升倍率：" << us1 / calc_us2(us1, us2) << std::endl << std::endl;

    delete[] a;
    delete[] b;
    delete[] c;
}

// TEST_INT_PLUS

void _emu_int_plus(const int a[], const int b[], int c[], int length)
{
    const int *pa = a;
    const int *pb = b;
    int *pc = c;
    while (length-- > 0) {
        *pc++ = *pa++ + *pb++;
    }
}

void test_int_plus(void)
{
    int *a = new int[ARRAY_COUNT];
    int *b = new int[ARRAY_COUNT];
    int *c = new int[ARRAY_COUNT];
    memset(a, 0, ARRAY_COUNT * sizeof(int));
    memset(b, 0, ARRAY_COUNT * sizeof(int));
    memset(c, 0, ARRAY_COUNT * sizeof(int));

    for (int i = 0; i < ARRAY_COUNT; ++i) {
        a[i] = -i;
        b[i] = -i - 1;
    }

    PreciTimer ptimer;
    long us1, us2 = 0;

    std::cout << std::endl;
    std::cout << "int型矢量相加测试结果：" << std::endl << std::endl;

    ptimer.reset();
    _emu_int_plus(a, b, c, ARRAY_COUNT);
    us1 = ptimer.ustick();
    std::cout << "仿真结果: " << us1 << " 微秒" << std::endl;
    ptimer.reset();
    JSimdVector::plus(a, b, c, ARRAY_COUNT);
    us2 = ptimer.ustick();
    std::cout << "SIMD结果: " << us2 << " 微秒" << std::endl;
    std::cout << "提升倍率：" << us1 / calc_us2(us1, us2) << std::endl << std::endl;

    delete[] a;
    delete[] b;
    delete[] c;
}

// TEST_INT_MINUS

void _emu_int_minus(const int a[], const int b[], int c[], int length)
{
    const int *pa = a;
    const int *pb = b;
    int *pc = c;
    while (length-- > 0) {
        *pc++ = *pa++ - *pb++;
    }
}

void test_int_minus(void)
{
    int *a = new int[ARRAY_COUNT];
    int *b = new int[ARRAY_COUNT];
    int *c = new int[ARRAY_COUNT];
    memset(a, 0, ARRAY_COUNT * sizeof(int));
    memset(b, 0, ARRAY_COUNT * sizeof(int));
    memset(c, 0, ARRAY_COUNT * sizeof(int));

    for (int i = 0; i < ARRAY_COUNT; ++i) {
        a[i] = -i;
        b[i] = -i - 1;
    }

    PreciTimer ptimer;
    long us1, us2 = 0;

    std::cout << std::endl;
    std::cout << "int型矢量相减测试结果：" << std::endl << std::endl;

    ptimer.reset();
    _emu_int_minus(a, b, c, ARRAY_COUNT);
    us1 = ptimer.ustick();
    std::cout << "仿真结果: " << us1 << " 微秒" << std::endl;
    ptimer.reset();
    JSimdVector::minus(a, b, c, ARRAY_COUNT);
    us2 = ptimer.ustick();
    std::cout << "SIMD结果: " << us2 << " 微秒" << std::endl;
    std::cout << "提升倍率：" << us1 / calc_us2(us1, us2) << std::endl << std::endl;

    delete[] a;
    delete[] b;
    delete[] c;
}

// TEST_FLOAT_PLUS

void _emu_float_plus(const float a[], const float b[], float c[], int length)
{
    const float *pa = a;
    const float *pb = b;
    float *pc = c;
    while (length-- > 0) {
        *pc++ = *pa++ + *pb++;
    }
}

void test_float_plus(void)
{
    simd_float *a = simd_malloc_float(ARRAY_COUNT);
    simd_float *b = simd_malloc_float(ARRAY_COUNT);
    simd_float *c = simd_malloc_float(ARRAY_COUNT);
    memset(a, 0, ARRAY_COUNT * sizeof(simd_float));
    memset(b, 0, ARRAY_COUNT * sizeof(simd_float));
    memset(c, 0, ARRAY_COUNT * sizeof(simd_float));

    for (int i = 0; i < ARRAY_COUNT; ++i) {
        a[i] = float(-i);
        b[i] = float(-i - 1);
    }

    PreciTimer ptimer;
    long us1, us2 = 0;

    std::cout << std::endl;
    std::cout << "float型矢量相加测试结果：" << std::endl << std::endl;

    ptimer.reset();
    _emu_float_plus(a, b, c, ARRAY_COUNT);
    us1 = ptimer.ustick();
    std::cout << "仿真结果: " << us1 << " 微秒" << std::endl;
    ptimer.reset();
    JSimdVector::plus(a, b, c, ARRAY_COUNT);
    us2 = ptimer.ustick();
    std::cout << "SIMD结果: " << us2 << " 微秒" << std::endl;
    std::cout << "提升倍率：" << us1 / calc_us2(us1, us2) << std::endl << std::endl;

    simd_free(a);
    simd_free(b);
    simd_free(c);
}

// TEST_FLOAT_MINUS

void _emu_float_minus(const float a[], const float b[], float c[], int length)
{
    const float *pa = a;
    const float *pb = b;
    float *pc = c;
    while (length-- > 0) {
        *pc++ = *pa++ - *pb++;
    }
}

void test_float_minus(void)
{
    simd_float *a = simd_malloc_float(ARRAY_COUNT);
    simd_float *b = simd_malloc_float(ARRAY_COUNT);
    simd_float *c = simd_malloc_float(ARRAY_COUNT);
    memset(a, 0, ARRAY_COUNT * sizeof(float));
    memset(b, 0, ARRAY_COUNT * sizeof(float));
    memset(c, 0, ARRAY_COUNT * sizeof(float));

    for (int i = 0; i < ARRAY_COUNT; ++i) {
        a[i] = float(-i);
        b[i] = float(-i - 1);
    }

    PreciTimer ptimer;
    long us1, us2 = 0;

    std::cout << std::endl;
    std::cout << "float型矢量相减测试结果：" << std::endl << std::endl;

    ptimer.reset();
    _emu_float_minus(a, b, c, ARRAY_COUNT);
    us1 = ptimer.ustick();
    std::cout << "仿真结果: " << us1 << " 微秒" << std::endl;
    ptimer.reset();
    JSimdVector::minus(a, b, c, ARRAY_COUNT);
    us2 = ptimer.ustick();
    std::cout << "SIMD结果: " << us2 << " 微秒" << std::endl;
    std::cout << "提升倍率：" << us1 / calc_us2(us1, us2) << std::endl << std::endl;

    simd_free(a);
    simd_free(b);
    simd_free(c);
}

// TEST_FLOAT_MULT

void _emu_float_mult(const float a[], const float b[], float c[], int length)
{
    const float *pa = a;
    const float *pb = b;
    float *pc = c;
    while (length-- > 0) {
        *pc++ = (*pa++) * (*pb++);
    }
}

void test_float_mult(void)
{
    simd_float *a = simd_malloc_float(ARRAY_COUNT);
    simd_float *b = simd_malloc_float(ARRAY_COUNT);
    simd_float *c = simd_malloc_float(ARRAY_COUNT);
    memset(a, 0, ARRAY_COUNT * sizeof(float));
    memset(b, 0, ARRAY_COUNT * sizeof(float));
    memset(c, 0, ARRAY_COUNT * sizeof(float));

    for (int i = 0; i < ARRAY_COUNT; ++i) {
        a[i] = float(-i);
        b[i] = float(-i - 1);
    }

    PreciTimer ptimer;
    long us1, us2 = 0;

    std::cout << std::endl;
    std::cout << "float型矢量相乘测试结果：" << std::endl << std::endl;

    ptimer.reset();
    _emu_float_mult(a, b, c, ARRAY_COUNT);
    us1 = ptimer.ustick();
    std::cout << "仿真结果: " << us1 << " 微秒" << std::endl;
    ptimer.reset();
    JSimdVector::mult(a, b, c, ARRAY_COUNT);
    us2 = ptimer.ustick();
    std::cout << "SIMD结果: " << us2 << " 微秒" << std::endl;
    std::cout << "提升倍率：" << us1 / calc_us2(us1, us2) << std::endl << std::endl;

    simd_free(a);
    simd_free(b);
    simd_free(c);
}

// TEST_FLOAT_MULT

void _emu_float_div(const float a[], const float b[], float c[], int length)
{
    const float *pa = a;
    const float *pb = b;
    float *pc = c;
    while (length-- > 0) {
        *pc++ = *pa++ / *pb++;
    }
}

void test_float_div(void)
{
    simd_float *a = simd_malloc_float(ARRAY_COUNT);
    simd_float *b = simd_malloc_float(ARRAY_COUNT);
    simd_float *c = simd_malloc_float(ARRAY_COUNT);
    memset(a, 0, ARRAY_COUNT * sizeof(float));
    memset(b, 0, ARRAY_COUNT * sizeof(float));
    memset(c, 0, ARRAY_COUNT * sizeof(float));

    for (int i = 0; i < ARRAY_COUNT; ++i) {
        a[i] = float(-i);
        b[i] = float(-i - 1);
    }

    PreciTimer ptimer;
    long us1, us2 = 0;

    std::cout << std::endl;
    std::cout << "float型矢量相除测试结果：" << std::endl << std::endl;

    ptimer.reset();
    _emu_float_div(a, b, c, ARRAY_COUNT);
    us1 = ptimer.ustick();
    std::cout << "仿真结果: " << us1 << " 微秒" << std::endl;
    ptimer.reset();
    JSimdVector::div(a, b, c, ARRAY_COUNT);
    us2 = ptimer.ustick();
    std::cout << "SIMD结果: " << us2 << " 微秒" << std::endl;
    std::cout << "提升倍率：" << us1 / calc_us2(us1, us2) << std::endl << std::endl;

    simd_free(a);
    simd_free(b);
    simd_free(c);
}
